package com.szrt.chenyangsen;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.junit.Test;

public class ArrayDemo {

	@Test
	public void test01() throws Exception {
		String[] arr = {"10","20","30"};
		String[] arr1= new String[arr.length+1];
		for(int index=0;index<arr.length;index++){
			arr1[index]=arr[index];
		}
		arr1[arr.length]="40";
		
		for(String str:arr1){
			System.out.println(str);
		}
		//Arrays.asList(arr1).contains("30");
		//List<String> list = Arrays.asList(arr1);
		//list.remove(list.indexOf("30"));
		//System.out.println(list.remove(list.indexOf("30")));
		String[] arr2= new String[arr.length];
		for(int index=0;index<arr1.length;index++){
			if(arr1[index].equals("30")){
				for(int i=0;i<index;i++){
					arr2[i]=arr1[i];
				}
				for(int j=index;j<arr2.length;j++){
					arr2[j]=arr1[j+1];
				}
			}
		}
		for(String st:arr2){
			System.err.println(st);
		}
		System.out.println(Arrays.asList(arr1));
	}
	
	
	@Test
	public void test2() throws Exception {
		List<String> list = new ArrayList<String>();
		list.add("10");
		list.add("20");
		list.add("30");
		list.add("40");
		//System.out.println(list);
		//list.remove("30");
		list.set(list.indexOf("30"), "50");
		//System.err.println(list.contains("20"));
		//list.contains("20");
		Iterator<String> it = list.iterator();
		while(it.hasNext()){
			String str = it.next();
			
			System.err.println(str);
		}
	}
	
	
	@Test
	public void test3() throws Exception {
		Set<String> set = new HashSet<String>();
		Set<String> se = new HashSet<String>();
		set.add("10");
		set.add("20");
		set.add("30");
		se.add("10");
		se.add("20");
		set.removeAll(se);
		System.out.println(set);
	}
}
